<%@page import="control.action.BaseAction"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html lang="en">
<%BaseAction.setBackUrl(request); %>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>作者注册</title>
    <link rel="stylesheet" href="layui/css/layui.css">
</head>
<style>
    body {
        width: 100%;
        height: 100%;
        background-color: #F2F2F2;
    }
    
    #backbox {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        min-width: 1000px;
        z-index: -10;
        zoom: 1;
        background-color: #fff;
        background-repeat: no-repeat;
        background-size: cover;
        -webkit-background-size: cover;
        -o-background-size: cover;
        background-position: center 0;
    }
    
    .blogerbox {
        height: 600px;
        width: 600px;
        background-color: white;
        margin: 20px auto;
    }
    
    .addtitle {
        font-size: 24px;
        color: cornflowerblue;
        background-color: rgb(222, 247, 222);
    }
    
    #upimg {
        width: 100%;
        height: 190px;
        border: 1px solid gray;
        margin-left: 3%;
    }
</style>

<body>
    <!--背景图片-->
    <div id="backbox" class="layui-bg-gray"></div>
    <!--注册表单区域-->
    <div class="layui-row blogerbox">
        <div class="layui-card">
            <div class="layui-card-header addtitle">填写用户基本信息</div>
            <div class="layui-card-body">
                <form class="layui-form" action="addauthoruser.action">
                    <div class="layui-col-md8">
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户账号：</label>
                            <div class="layui-input-block">
                                <input type="text" name="user.userid" id="userid" required lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input" value="${loginuser.userid}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户昵称：</label>
                            <div class="layui-input-block">
                                <input type="text" name="user.nickname" required lay-verify="required" placeholder="请输入昵称" autocomplete="off" class="layui-input" value="${loginuser.nickname}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">真实姓名：</label>
                            <div class="layui-input-block">
                                <input type="text" name="user.realname" required lay-verify="required" placeholder="请输入真实姓名" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">联系电话：</label>
                            <div class="layui-input-block">
                                <input type="text" name="user.mobile" required lay-verify="required" placeholder="请输入联系电话" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户照片：</label>
                            <div class="layui-input-block">
                                <input type="text" name="user.userphoto" id="photoname" required lay-verify="required" readonly="true" placeholder="请输上传一张作者照片" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">性别：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="user.agend" value="男" title="男" checked>
                                <input type="radio" name="user.agend" value="女" title="女">
                            </div>
                        </div>
                    </div>
                    <!--上传照片-->
                    <div class="layui-col-md4">
                        <div class="layui-form-item">
                            <div class="layui-upload">
                                <div class="layui-upload-list">
                                    <img src="img/defaultuser.jpg" class="layui-upload-img" id="upimg" />
                                </div>
                                <button type="button" name="btnaddphoto" class="layui-btn layui-btn-normal" id="uptest" style="margin-left:25%">上传作者照片</button>
                                <p id="demoText" style="margin-left: 30%"></p>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">个性签名：</label>
                        <div class="layui-input-block">
                            <textarea name="user.signature" placeholder="请输入内容" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</body>
<script src="layui/layui.js"></script>
<script>
    //Demo
    layui.use(['form', 'laydate'], function() {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate;
        //日期
        laydate.render({
            elem: '#date1'
        });
    });
    //图片上传
   	layui.use('upload', function() {
        var $ = layui.jquery,
            upload = layui.upload;

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#uptest',
            url:'fileupload.do?path=' + $("#userid").val(),
            before: function(obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result) {
                    $('#upimg').attr('src', result); //图片链接（base64）
                });
               
            },
            done: function(res) {
				$('#photoname').val(res.result1);
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
            },
            error: function() {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function() {
                    uploadInst.upload();
                });
            }
        });
    });
</script>

</html>